package tlcn.data;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;

import android.content.res.AssetManager;

public class CopyDB {
	public void copy(AssetManager assetManager) {
		
		File f=new File("/data/data/tlcn.app/databases");
		if(!f.exists()){
				f.mkdir();
		}
		File db = new File("/data/data/tlcn.app/databases/DataBase.sqlite");
		InputStream inputStream = null;
		FileOutputStream fileOutputStream = null;
		
		try {
			inputStream = assetManager.open("DataBase.sqlite");
			byte[] buffer = new byte[inputStream.available()];
			inputStream.read(buffer);

			fileOutputStream = new FileOutputStream(db);
			fileOutputStream.write(buffer);

		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			try {
				inputStream.close();
				fileOutputStream.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

		}
	}
}
